32 research outputs found
Directed Containers as Categories
Directed containers make explicit the additional structure of those
containers whose set functor interpretation carries a comonad structure. The
data and laws of a directed container resemble those of a monoid, while the
data and laws of a directed container morphism those of a monoid morphism in
the reverse direction. With some reorganization, a directed container is the
same as a small category, but a directed container morphism is opcleavage-like.
We draw some conclusions for comonads from this observation, considering in
particular basic constructions and concepts like the opposite category and a
groupoid.Comment: In Proceedings MSFP 2016, arXiv:1604.0038
Handling Fibred Algebraic Effects
International audienceWe study algebraic computational effects and their handlers in the dependently typed setting. We describecomputational effects using a generalisation of Plotkin and Pretnar’s effect theories, whose dependentlytyped operations allow us to capture precise notions of computation, e.g., state with location-dependent storetypes and dependently typed update monads. Our treatment of handlers is based on an observation that theirconventional term-level definition leads to unsound program equivalences being derivable in languages thatinclude a notion of homomorphism. We solve this problem by giving handlers a novel type-based treatmentvia a new computation type, the user-defined algebra type, which pairs a value type (the carrier) with a set ofvalue terms (the operations), capturing Plotkin and Pretnar’s insight that effect handlers denote algebras. Wethen show that the conventional presentation of handlers can be routinely derived, and demonstrate that thistype-based treatment of handlers provides a useful mechanism for reasoning about effectful computations.We also equip the resulting language with a sound denotational semantics based on families fibrations
When is a container a comonad?
Abbott, Altenkirch, Ghani and others have taught us that many parameterized
datatypes (set functors) can be usefully analyzed via container representations
in terms of a set of shapes and a set of positions in each shape. This paper
builds on the observation that datatypes often carry additional structure that
containers alone do not account for. We introduce directed containers to
capture the common situation where every position in a data-structure
determines another data-structure, informally, the sub-data-structure rooted by
that position. Some natural examples are non-empty lists and node-labelled
trees, and data-structures with a designated position (zippers). While
containers denote set functors via a fully-faithful functor, directed
containers interpret fully-faithfully into comonads. But more is true: every
comonad whose underlying functor is a container is represented by a directed
container. In fact, directed containers are the same as containers that are
comonads. We also describe some constructions of directed containers. We have
formalized our development in the dependently typed programming language Agda
Decomposing Comonad Morphisms
The analysis of set comonads whose underlying functor is a container functor in terms of directed containers makes it a simple observation that any morphism between two such comonads factors through a third one by two comonad morphisms, whereof the first is identity on shapes and the second is identity on positions in every shape. This observation turns out to generalize into a much more involved result about comonad morphisms to comonads whose underlying functor preserves Cartesian natural transformations to itself on any category with finite limits. The bijection between comonad coalgebras and comonad morphisms from costate comonads thus also yields a decomposition of comonad coalgebras
Coalgebraic Update Lenses
AbstractLenses are mathematical structures used in the context of bidirectional transformations.In this paper, we introduce update lenses as a refinement of ordinary (asymmetric) lenses in which we distinguish between views and updates. In addition to the set of views, there is a monoid of updates and an action of the monoid on the set of views. Decoupling updates from views allows for other ways of changing the source than just merging a view into the source. We also consider a yet finer dependently typed version of update lenses.We give a number of characterizations of update lenses in terms of bialgebras and coalgebras, including analogs to O'Connor's coalgebraic and Johnson, Rosebrugh and Wood's algebraic characterizations of ordinary lenses. We consider conversion of views and updates, a tensor product of update lenses and composition of update lenses
Runners in action
Runners of algebraic effects, also known as comodels, provide a mathematical
model of resource management. We show that they also give rise to a programming
concept that models top-level external resources, as well as allows programmers
to modularly define their own intermediate "virtual machines". We capture the
core ideas of programming with runners in an equational calculus
, which we equip with a sound and coherent
denotational semantics that guarantees the linear use of resources and
execution of finalisation code. We accompany with
examples of runners in action, provide a prototype language implementation in
OCaml, as well as a Haskell library based on .Comment: ESOP 2020 final version + online appendi
Fibred computational effects
We study the interplay between dependent types and computational effects, two important
areas of modern programming language research. On the one hand, dependent
types underlie proof assistants such as Coq and functional programming languages
such as Agda, Idris, and F*, providing programmers a means for encoding detailed
specifications of program behaviour using types. On the other hand, computational
effects, such as exceptions, nondeterminism, state, I/O, probability, etc., are integral to
all widely-used programming languages, ranging from imperative languages, such as
C, to functional languages, such as ML and Haskell. Separately, dependent types and
computational effects both come with rigorous mathematical foundations, dependent
types in the effect-free setting and computational effects in the simply typed setting.
Their combination, however, has received much less attention and no similarly exhaustive
theory has been developed. In this thesis we address this shortcoming by providing
a comprehensive treatment of the combination of these two fields, and demonstrating
that they admit a mathematically elegant and natural combination.
Specifically, we develop a core effectful dependently typed language, eMLTT,
based on Martin-L¨of’s intensional type theory and a clear separation between (effect-free)
values and (possibly effectful) computations familiar from simply typed languages
such as Levy’s Call-By-Push-Value and Egger et al.’s Enriched Effect Calculus.
A novel feature of our language is the computational S-type, which we use to give a
uniform treatment of type-dependency in sequential composition. In addition, we define
and study a class of category-theoretic models, called fibred adjunction models,
that are suitable for defining a sound and complete interpretation of eMLTT. Specifically,
fibred adjunction models naturally combine standard category-theoretic models
of dependent types (split closed comprehension categories) with those of computational
effects (adjunctions). We discuss and study various examples of these models,
including a domain-theoretic model so as to extend eMLTT with general recursion.
We also investigate a dependently typed generalisation of the algebraic treatment of
computational effects by showing how to extend eMLTT with fibred algebraic effects
and their handlers. In particular, we specify fibred algebraic effects using a dependently
typed generalisation of Plotkin and Pretnar’s effect theories, enabling us to capture
precise notions of computation such as state with location-dependent store types
and dependently typed update monads. For handlers, we observe that their conventional
term-level definition leads to unsound program equivalences becoming derivable
in languages that include a notion of homomorphism, such as eMLTT. To solve this
problem, we propose a novel type-based treatment of handlers via a new computation
type, the user-defined algebra type, which pairs a value type (the carrier) with a family
of value terms (the operations). This type internalises Plotkin and Pretnar’s insight that
handlers denote algebras for a given equational theory of computational effects. We
demonstrate the generality of our type-based treatment of handlers by showing that
their conventional term-level presentation can be routinely derived, and this treatment
provides a useful mechanism for reasoning about effectful computations. Finally, we
show that these extensions of eMLTT can be soundly interpreted in a fibred adjunction
model based on the families of sets fibration and models of Lawvere theories
SteelCore: An extensible concurrent separation logic for effectful dependently typed programs
Much recent research has been devoted to modeling effects within type theory. Building on this work, we observe that effectful type theories can provide a foundation on which to build semantics for more complex programming constructs and program logics, extending the reasoning principles that apply within the host effectful type theory itself. Concretely, our main contribution is a semantics for concurrent separation logic (CSL) within the F* proof assistant in a manner that enables dependently typed, effectful F* programs to make use of concurrency and to be specified and verified using a full-featured, extensible CSL. In contrast to prior approaches, we directly derive the partial-correctness Hoare rules for CSL from the denotation of computations in the effectful semantics of non-deterministically interleaved atomic actions. Demonstrating the flexibility of our semantics, we build generic, verified libraries that support various concurrency constructs, ranging from dynamically allocated, storable spin locks, to protocol-indexed channels. We conclude that our effectful semantics provides a simple yet expressive basis on which to layer domain-specific languages and logics for verified, concurrent programming.Fil: Swamy, Nikhil. Microsoft Research; Estados UnidosFil: Rastogi, Aseem. Microsoft Research; IndiaFil: Fromherz, Aymeric. University of Carnegie Mellon; Estados UnidosFil: Merigoux, Denis. Institut National de Recherche en Informatique et en Automatique; FranciaFil: Ahman, Danel. University of Ljubljana; EsloveniaFil: MartÃnez, Guido. Consejo Nacional de Investigaciones CientÃficas y Técnicas. Centro CientÃfico Tecnológico Conicet - Rosario. Centro Internacional Franco Argentino de Ciencias de la Información y de Sistemas. Universidad Nacional de Rosario. Centro Internacional Franco Argentino de Ciencias de la Información y de Sistemas; Argentin